]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
loginDialog: Add ConflictingSessionDialog
authorJoan Torres <joan.torres@suse.com>
Wed, 7 Feb 2024 12:03:11 +0000 (13:03 +0100)
committerRay Strode <halfline@gmail.com>
Thu, 29 Feb 2024 20:42:52 +0000 (20:42 +0000)
This dialog will be used by the next commit when a session is being opened but
there's already a conflicting session opened.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3134>

data/theme/gnome-shell-sass/widgets/_login-lock.scss
js/gdm/loginDialog.js

index 87ed1cad9952f615503aca7246d3dec003de1ca7..52441a5c1f7267dc4b28fdc337ea3fd62763ede0 100644 (file)
@@ -45,6 +45,25 @@ $_gdm_dialog_width: 25em;
   spacing: $base_padding * 2;
 }
 
+.conflicting-session-dialog-content {
+  spacing: 20px;
+
+  .conflicting-session-dialog-title {
+    text-align: center;
+    @extend %title_2;
+    margin-bottom: 5px;
+  }
+
+  .conflicting-session-dialog-desc {
+    text-align: center;
+  }
+
+  .conflicting-session-dialog-desc-warning {
+    text-align: center;
+    color: $warning_color;
+  }
+}
+
 .login-dialog-logo-bin {
   margin: 3em 0;
 }
index f978112998c5070be94c371d544f89c5ff99bbcd..09b68b42f1fa0a24fcf4e840af2d17898bebe891 100644 (file)
@@ -36,6 +36,7 @@ import * as GdmUtil from './util.js';
 import * as Layout from '../ui/layout.js';
 import * as LoginManager from '../misc/loginManager.js';
 import * as Main from '../ui/main.js';
+import * as ModalDialog from '../ui/modalDialog.js';
 import * as PopupMenu from '../ui/popupMenu.js';
 import * as Realmd from './realmd.js';
 import * as UserWidget from '../ui/userWidget.js';
@@ -406,6 +407,76 @@ const SessionMenuButton = GObject.registerClass({
     }
 });
 
+export const ConflictingSessionDialog = GObject.registerClass({
+    Signals: {
+        'cancel': {},
+        'force-stop': {},
+    },
+}, class ConflictingSessionDialog extends ModalDialog.ModalDialog {
+    _init(conflictingSession, greeterSession, userName) {
+        super._init();
+
+        let bannerText;
+        if (greeterSession.Remote && conflictingSession.Remote)
+            /* Translators: is running for <username> */
+            bannerText = _('Remote login is not possible because a remote session is already running for %s. To login remotely, you must log out from the remote session or force stop it.').format(userName);
+        else if (!greeterSession.Remote && conflictingSession.Remote)
+            /* Translators: is running for <username> */
+            bannerText = _('Login is not possible because a remote session is already running for %s. To login, you must log out from the remote session or force stop it.').format(userName);
+        else if (greeterSession.Remote && !conflictingSession.Remote)
+            /* Translators: is running for <username> */
+            bannerText = _('Remote login is not possible because a local session is already running for %s. To login remotely, you must log out from the local session or force stop it.').format(userName);
+        else
+            /* Translators: is running for <username> */
+            bannerText = _('Login is not possible because a session is already running for %s. To login, you must log out from the session or force stop it.').format(userName);
+
+        let textLayout = new St.BoxLayout({
+            style_class: 'conflicting-session-dialog-content',
+            vertical: true,
+            x_expand: true,
+        });
+
+        let title = new St.Label({
+            text: _('Session Already Running'),
+            style_class: 'conflicting-session-dialog-title',
+        });
+
+        let banner = new St.Label({
+            text: bannerText,
+            style_class: 'conflicting-session-dialog-desc',
+        });
+        banner.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
+        banner.clutter_text.line_wrap = true;
+
+        let warningBanner = new St.Label({
+            text: _('Force stopping will quit any running apps and processes, and could result in data loss.'),
+            style_class: 'conflicting-session-dialog-desc-warning',
+        });
+        warningBanner.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
+        warningBanner.clutter_text.line_wrap = true;
+
+        textLayout.add_child(title);
+        textLayout.add_child(banner);
+        textLayout.add_child(warningBanner);
+        this.contentLayout.add_child(textLayout);
+
+        this.addButton({
+            label: _('Cancel'),
+            action: () => {
+                this.emit('cancel');
+            },
+            key: Clutter.KEY_Escape,
+            default: true,
+        });
+        this.addButton({
+            label: _('Force Stop'),
+            action: () => {
+                this.emit('force-stop');
+            },
+        });
+    }
+});
+
 export const LoginDialog = GObject.registerClass({
     Signals: {
         'failed': {},